package design.test2Proxy.dynamicproxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

public class ProxyFactoryBean implements InvocationHandler {
private Object obj;

/**
 */
public Object createProxyInstance(Object obj){
    this.obj=obj;
    ClassLoader loader=obj.getClass().getClassLoader();
    Class<?>[] objInterfaces=obj.getClass().getInterfaces();
    return Proxy.newProxyInstance(loader, objInterfaces, this);
}

/**

 */
@Override
public Object invoke(Object proxy, Method method, Object[] args)
        throws Throwable {
    System.out.println("11111");

    Object object=method.invoke(obj, args);
    System.out.println("22222");
    return object;
}
}
